/**
 * 
 */
package com.lemote.service.account.impl;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.lemote.dao.account.UserDao;
import com.lemote.entity.User;
import com.lemote.service.account.UserService;
import com.lemote.service.impl.BaseServiceImpl;

/**
 * @author wuhui
 * 
 *         下午04:18:44
 */
@Component
@Transactional
public class UserServiceImpl extends BaseServiceImpl<User, Long, UserDao>
		implements UserService {

	@Autowired
	@Override
	public void setEntityDao(UserDao userDao) {

		this.entityDao = userDao;
	}

	/**
	 * 用户登陆
	 */
	public User login(String loginName, String password) {
		
		String hql = "from User u  where u.workCard = ? and u.password = ? ";
		String[] values = {loginName,password};
		return entityDao.findUnique(hql,values);
	}
	
	public Integer isLoginNameUnique(String loginName){
		String hql = "select u.id from User u  where u.workCard = ? ";
		String[] values = {loginName};
		List<User> users = entityDao.find(hql, values);
		if (users==null) {
			return 0;
		}
		return users.size();
	}

}
